<?php
/*
 * @Author: your name
 * @Date: 2020-12-29 10:48:29
 * @LastEditTime: 2020-12-29 10:59:43
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /uma-api/laravel/database/migrations/2020_12_29_114829_create_customers_table.php
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('temporary_member_id', 128)->unique()->comment('会員仮ID');
            $table->unsignedBigInteger('company_id')->nullable()->comment('会社ID');
            $table->string('api_token', 64)->unique()->comment('トークン');
            $table->timestamp('token_updated_at', 0)->comment('トークン作成更新日時');
            $table->timestamps();
            //$table->foreign('company_id')->nullable()->references('id')->on('companies');
            $table->index('api_token');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customers');
    }
}
